package com.preparation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.preparation.domain.Collection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CollectionMapper extends BaseMapper<Collection> {

    //根据用户id 帖子id删除收藏信息
    @Delete("DELETE FROM tbl_post_collect WHERE user_id=#{userId} AND post_id=#{postId}")
    int deleteByUidPid(Collection collection);

    //根据用户id和帖子id查询用户是否收藏
    @Select("select count(*) from tbl_post_collect where user_id=#{userId} and post_id=#{postId}")
    int getByUidPid(Collection collection);

    //根据用户id查询用户的收藏信息的帖子id列表
    @Select("select post_id from tbl_post_collect where user_id=#{userId}")
    List<Integer> getByUid(Integer userId);

}
